def solve(ransomNote, magazine):
    mag_dict = {}
    for c in magazine:
        if c not in mag_dict:
            mag_dict[c] = 1
        else:
            mag_dict[c] += 1

    for c in ransomNote:
        if c not in mag_dict:
            return False
        else:
            mag_dict[c] -= 1

        if mag_dict[c] < 0:
            return False

    return True


if __name__ == "__main__":
    ransomNote = "aa"
    magazine = "aab"
    print(solve(ransomNote, magazine))
